package com.bsoft.factoryprovider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by 泅渡者
 * Created on 2017/9/28.
 */

public class DBHelper extends SQLiteOpenHelper {
    public static final String DB_NAME = "Factory.db";
    public static final String DB_TABLE = "Goods";
    public static final int DB_VERSION = 1;
    /**
     * 创建数据库SQL
     **/
    private static final String DB_CREATE = "CREATE TABLE " + DB_TABLE + "("
            + Goods.ID + " INTEGER PRIMARY KEY, "
            + Goods.NAME + " text not null, "
            + Goods.DESC + " text not null, "
            + Goods.URL + " text not null "
            + ")";

    public DBHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DB_CREATE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE);
        onCreate(db);
    }
}
